package com.liting.uitest.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.Collections;

@Configuration
@EnableOpenApi
public class SwaggerConfig {
    //配置Swagger的Docket的实例，Swagger页面展示的信息，都在此处配置；如果要配置多个分组，就创建多个Docket实例
    @Bean
    public Docket getDocket() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .groupName("uitest")
                .select()
                //指定扫描的包或者注解
                .apis(RequestHandlerSelectors.basePackage("com.liting.uitest.controller").or(RequestHandlerSelectors.withClassAnnotation(RestController.class)))
                //过滤，只扫描带有下面请求路径的接口
//                .paths(PathSelectors.ant("/yuhuofei/**"))
                .build();
    }

    //配置Swagger的apiInfo
    private ApiInfo apiInfo() {

        //Contact contact = new Contact("liting", "https://blog.csdn.net/Crezfikbd?type=blog", "xdssxxxxx.@qq.com");

        return new ApiInfo("界面评价软件",
                "接口文档",
                "v1.0",
                "https:127.0.0.1",
                null,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<>()
        );

    }

}
